<? require_once("sitemap.php"); ?>
<?
$action="start";

if (!empty($_POST['action']))
{
	$action = $_POST['action'];
}
if (!empty($_POST['searchitemname']))
{
	$searchitemname = $_POST['searchitemname'];
}
if (!empty($_POST['searchplayername']))
{
	$searchplayername = $_POST['searchplayername'];
}
?>
<html>
	<title><? echo (":" . $HTTP_SERVER_VARS['REMOTE_USER'] . ": ". $Botname); ?>'s EL-BOT Give Log</title>
<body>
	<h1><? echo ($Botname); ?>'s EL-BOT Give Log</h1>

	<? include "maxlisting.php" ?>
<?
$sql = "SELECT tradelog.id, tradelog.knownitemsid, knownitems.name, tradelog.quantity, tradelog.price, tradelog.username, tradelog.tradetime, tradelog.action FROM tradelog,knownitems WHERE tradelog.knownitemsid=knownitems.id AND tradelog.botid=$botid ";
if($searchitemname != "")
	$sql .= "AND knownitems.name LIKE '%$searchitemname%' ";
if($searchplayername != "")
	$sql .= "AND tradelog.username LIKE '%$searchplayername%' ";
$sql .= "AND tradelog.action = 'give' ORDER BY tradelog.id DESC LIMIT $max";
$result = mysql_query($sql,$db);
echo mysql_num_rows($result) . " actions returned";
?>
	<table border="1" cellpadding="0" cellspacing="0">
		<tr>
			<td align="center">id</td>
			<td align="center">name<br>
<form method="post" action = "<? echo $_SERVER['PHP_SELF']; ?>" onSubmit="return false;"><input type="text" name = "searchitemname" value="<?php echo $searchitemname ?>" onchange="this.form.submit();"><input type="submit" name = 'submit_1' value = 'reload'>
</td>
			<td align="center">quantity</td>
			<td align="center">username<br>
<input type="text" name = "searchplayername" value="<?php echo $searchplayername ?>" onchange="this.form.submit();"><input type="submit" name = 'submit_' value = 'reload'></form>
</td>
			<td align="center">Date</td>
		</tr>
		<?php
			while ($myrow = mysql_fetch_row($result))
			{
		?>
			<tr>
					<td align="right"><?echo ($myrow[0])?></td>
					<td><?echo ($myrow[2])?></td>
					<td align="right"><?echo ($myrow[3])?></td>
					<td><?echo ($myrow[5])?></td>
					<td><?echo ($myrow[6])?></td>
			</tr>
			<?
			}
			?>
	</table>
</body>
</html>
